<%@page import="doan.quanlycanbo.portlet.model.impl.hosoImpl"%>
<%@page import="java.util.GregorianCalendar"%>
<%@page import="doan.quanlycanbo.portlet.service.dantocLocalServiceUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ include file="/init.jsp" %>

<%
	long idHoso = Long.valueOf(request.getParameter("idHoso")) ;
// 	User userAddProfile = UserLocalServiceUtil.getUser(userId);
// 	Long profileId = (Long)userAddProfile.getExpandoBridge().getAttribute("idHoso") ;
// 	String profileIds = renderRequest.getParameter("profileId");
	hoso hosoUpdate = new hosoImpl();
	Calendar calendar = GregorianCalendar.getInstance();
	int dayDOB = calendar.get(Calendar.DAY_OF_MONTH);
	int monthDOB= calendar.get(Calendar.MONTH);
	int yearDOB = calendar.get(Calendar.YEAR);
	int dayVaoDang = calendar.get(Calendar.DAY_OF_MONTH);;
	int monthVaoDang = calendar.get(Calendar.MONTH);
	int yearVaoDang = calendar.get(Calendar.YEAR);
	boolean daVaoDang = false;
	
	if(idHoso > 0){
		hosoUpdate = hosoLocalServiceUtil.getByPrimaryKey(idHoso);	
		if(hosoUpdate.getNgaysinh() != null){
		calendar.setTime(hosoUpdate.getNgaysinh());
		dayDOB = calendar.get(Calendar.DAY_OF_MONTH);
		monthDOB = calendar.get(Calendar.MONTH);
		yearDOB = calendar.get(Calendar.YEAR);
		}
		
		if(hosoUpdate.getNgayvaodang() != null){
		calendar.setTime(hosoUpdate.getNgayvaodang());
		dayVaoDang = calendar.get(Calendar.DAY_OF_MONTH);
		monthVaoDang = calendar.get(Calendar.MONTH);
		yearVaoDang = calendar.get(Calendar.YEAR);
		daVaoDang = true;
		}
	}
// 	long profileId = Long.valueOf(renderRequest.getParameter("profileId"));
// // 	hoso hosoUpdate = hosoLocalServiceUtil.getByPrimaryKey(profileId);
	
	List<donvi> donviList = donviLocalServiceUtil.getAll();
	List<chucvu> chucvuList = chucvuLocalServiceUtil.getAll();
	List<dantoc> dantocList = dantocLocalServiceUtil.getAll();
	List<hocham> hochamList = hochamLocalServiceUtil.getAll();
	List<hocvi> hocviList = hocviLocalServiceUtil.getAll();
	List<hesoluong> hesoluongList = hesoluongLocalServiceUtil.getAll();
	List<capuy> capuyList = capuyLocalServiceUtil.getAll();
	List<tongiao> tongiaoList = tongiaoLocalServiceUtil.getAll();
	List<xuatthan> xuatthanList = xuatthanLocalServiceUtil.getAll();
	List<giaoducphothong> gdptList = giaoducphothongLocalServiceUtil.getAll();
	List<danhhieu> danhhieuList = danhhieuLocalServiceUtil.getAll();
%>

<script type="text/javascript">	
	function <portlet:namespace />disableInputDate() {		
		var checkbox = document.getElementById('<portlet:namespace />joinDate');
		var date = document.getElementById('<portlet:namespace />date');		
		
		if (checkbox.checked){
			date.style.display = '';
		}else {
			date.style.display = 'none';
		}		
	};	
</script>

<portlet:actionURL name="updateProfile" var="updateProfileURL"/>

	<aui:form name="fm" Method="post" action="<%= updateProfileURL.toString() %>" enctype="multipart/form-data">
		<aui:input type="hidden" name="idHoso" value="<%=idHoso %>"/>
<%-- 		<aui:input type="hidden" name="userId" value="<%= userId %>"/> --%>
		<table >
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-website","Hinh Anh") %></td>
				<td><aui:input name="hinhanh" type="file" label=""/> </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Ho ten") %></td>
				<td align="left"><aui:input name="hoten" label="" value="<%= hosoUpdate.getHoten() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","So hieu nhan vien") %></td>
				<td align="left"><aui:input name="sohieunv" label="" value="<%= hosoUpdate.getMahoso() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Chung minh nd") %></td>
				<td align="left"><aui:input name="cmtnd" label="" value="<%=hosoUpdate.getCmtnd() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Ten thuong dung") %></td>
				<td align="left"><aui:input name="tenthuongdung" label="" value="<%= hosoUpdate.getTenthuongdung() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Gioi tinh") %></td>
				<td><aui:select name="gioitinh" label=""  style="width:200px">
							<aui:option value="nam" selected="<%= hosoUpdate.getGioitinh().equals(\"nam\") %>" > Nam</aui:option>
							<aui:option value="nu" selected="<%= hosoUpdate.getGioitinh().equals(\"nu\") %>" > Nu</aui:option>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Ngay sinh") %></td>
				<td align="left"> <liferay-ui:input-date 
 								disableNamespace="<%= true %>" 
								dayParam="dayDOB"
								dayValue="<%= dayDOB %>"
								monthParam="monthDOB"
								monthValue="<%= monthDOB %>"
								yearParam="yearDOB"
								yearValue="<%= yearDOB %>"
								yearRangeStart="<%= calendar.get(Calendar.YEAR) - 100 %>"
								yearRangeEnd="<%= calendar.get(Calendar.YEAR) %>" 
								firstDayOfWeek="<%= calendar.getFirstDayOfWeek() - 1 %>"
                            	disabled="<%= false %>"
								 />
				 
				</td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Noi sinh") %></td>
				<td align="left"><aui:input name="noisinh" label="" value="<%= hosoUpdate.getNoisinh() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Que quan") %></td>
				<td align="left"><aui:input name="quequan" label="" value="<%= hosoUpdate.getQuequan() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Dia chi thuong tru") %></td>
				<td align="left"><aui:input name="diachithuongtru" label="" value="<%= hosoUpdate.getDiachithuongtru() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Dia chi tam tru") %></td>
				<td align="left"><aui:input name="diachitamtru" label="" value="<%= hosoUpdate.getDiachitamtru() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Dien thoai") %></td>
				<td align="left"><aui:input name="dienthoai" label="" value="<%= hosoUpdate.getDienthoai() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Email") %></td>
				<td align="left"><aui:input name="email" label="" value="<%= hosoUpdate.getEmail() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Quoc gia") %></td>
				<td align="left"><aui:input name="quocgia" label="" value="<%= hosoUpdate.getQuocgia() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Ngay vao Dang") %></td>
				<td align="left"> 
				 	<table>
     					<tr height="30">
     						<td>
    							 &nbsp;<input type="checkbox" name="<portlet:namespace/>joinDate" id="<portlet:namespace/>joinDate" 
								 onClick="javascript:<portlet:namespace />disableInputDate();" />
								<label for="<portlet:namespace/>joinDate" >Da vao Dang</label>
     						</td>
     					</tr>
    					<tr height="30" id="<portlet:namespace/>date" >
       						<td align="left"  >
       							<liferay-ui:input-date 
 								disableNamespace="<%= true %>" 
								dayParam="dayVaoDang"
								dayValue="<%= dayVaoDang %>"
								monthParam="monthVaoDang"
								monthValue="<%= monthVaoDang %>"
								yearParam="yearVaoDang"
								yearValue="<%= yearVaoDang %>"
								yearRangeStart="<%= calendar.get(Calendar.YEAR) - 100 %>"
								yearRangeEnd="<%= calendar.get(Calendar.YEAR) %>" 
								firstDayOfWeek="<%= calendar.getFirstDayOfWeek() - 1 %>"
                            	disabled="<%= false %>"
								 />
       						</td>
    					</tr>
  					</table>
				</td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Chuyen nganh tn1") %></td>
				<td align="left"><aui:input name="cntn1" label="" value="<%= hosoUpdate.getChuyennganh1() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Nam tncn1") %></td>
				<td align="left"><aui:input name="namtn1" label="" value="<%= hosoUpdate.getNamtncn1() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Chuyen nganh tn2") %></td>
				<td align="left"><aui:input name="cntn2" label="" value="<%= hosoUpdate.getChuyennganh2() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Nam tncn2") %></td>
				<td align="left"><aui:input name="namtn2" label="" value="<%= hosoUpdate.getNamtncn2() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Chuyen nganh tn3") %></td>
				<td align="left"><aui:input name="cntn3" label="" value="<%= hosoUpdate.getChuyennganh3() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Nam tncn3") %></td>
				<td align="left"><aui:input name="namtn3" label="" value="<%= hosoUpdate.getNamtncn3() %>"  style="width:350px" />  </td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Dan toc") %></td>
				<td><aui:select name="dantoc" label=""  style="width:200px">
						<aui:option value="0" >---Dan toc---</aui:option>
						<% for(dantoc dt : dantocList) {%>
							<aui:option value="<%= dt.getMadantoc() %>" selected="<%= dt.getMadantoc() == hosoUpdate.getMadantoc() %>">  <%= dt.getTendantoc() %></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Hoc ham") %></td>
				<td><aui:select name="hocham" label=""  style="width:200px">	
						<aui:option value="0" >---Hoc ham---</aui:option>
						<% for(hocham hh : hochamList) {%>
							<aui:option value="<%= hh.getMahocham() %>" selected="<%= hh.getMahocham() == hosoUpdate.getMahocham() %>">  <%= hh.getTenhocham() %></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Hoc vi") %></td>
				<td><aui:select name="hocvi" label=""  style="width:200px">
						<aui:option value="0" >---Hoc vi---</aui:option>
						<% for(hocvi hv : hocviList) {%>
							<aui:option value="<%= hv.getMahocvi() %>" selected="<%= hv.getMahocvi() == hosoUpdate.getMahocvi() %>">  <%= hv.getTenhocvi() %></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","He so luong") %></td>
				<td><aui:select name="hesoluong" label=""  style="width:200px">
						<aui:option value="0" >---He so luong---</aui:option>
						<% for(hesoluong hsl : hesoluongList) {%>
							<aui:option value="<%= hsl.getMahesoluong() %>" selected="<%= hsl.getMahesoluong() == hosoUpdate.getMahesoluong() %>">  <%= hsl.getHesoluong() %></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Cap uy") %></td>
				<td><aui:select name="capuy" label=""  style="width:200px">
						<aui:option value="0" >---Cap uy---</aui:option>
						<% for(capuy capUy : capuyList) {%>
							<aui:option value="<%= capUy.getMacapuy() %>" selected="<%= capUy.getMacapuy() == hosoUpdate.getMacapuy() %>">  <%= capUy.getTencapuy()%></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Ton giao") %></td>
				<td><aui:select name="tongiao" label=""  style="width:200px">
						<aui:option value="0" >---Ton giao---</aui:option>
						<% for(tongiao tg : tongiaoList) {%>
							<aui:option value="<%= tg.getMatongiao() %>" selected="<%= tg.getMatongiao() == hosoUpdate.getMatongiao() %>">  <%= tg.getTentongiao() %></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Xuat than") %></td>
				<td><aui:select name="xuatthan" label=""  style="width:200px">
						<aui:option value="0" >---Xuat than---</aui:option>
						<% for(xuatthan xt : xuatthanList) {%>
							<aui:option value="<%= xt.getMaxuatthan() %>" selected="<%= xt.getMaxuatthan() == hosoUpdate.getMaxuatthan() %>">  <%= xt.getTenxuatthan() %></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Giao duc pho thong") %></td>
				<td><aui:select name="gdpt" label=""  style="width:200px">	
						<aui:option value="0" >---Giao duc pho thong---</aui:option>
						<% for(giaoducphothong gdpt : gdptList) {%>
							<aui:option value="<%= gdpt.getMagdpt() %>" selected="<%= gdpt.getMagdpt() == hosoUpdate.getMagdpt() %>">  <%= gdpt.getTengdpt() %></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td width="20%"><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-agency","Danh hieu") %></td>
				<td><aui:select name="danhhieu" label=""  style="width:200px">
						<aui:option value="0" >---Danh hieu---</aui:option>
						<% for(danhhieu dh : danhhieuList) {%>
							<aui:option value="<%= dh.getMadanhhieu() %>" selected="<%= dh.getMadanhhieu() == hosoUpdate.getMadanhhieu() %>">  <%= dh.getTendanhhieu() %></aui:option>
					<% }%>
					</aui:select></td>
			</tr>
			<tr height="30">
				<td><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-select.agency.parent","Chuc vu") %></td>
				<td><aui:select name="chucvu" label=""  style="width:200px">
						<aui:option value="0" >---Chuc vu---</aui:option>
						<% for(chucvu cv : chucvuList) {%>
							<aui:option value="<%= cv.getMachucvu() %>" selected="<%= cv.getMachucvu() == hosoUpdate.getMachucvu() %>">  <%= cv.getTenchucvu() %></aui:option>							
						<% }%>
					</aui:select></td>
			</tr>	
			<tr height="30">
				<td><%=LanguageUtil.get(pageContext, "managecontacts.agency.add-select.agency.parent","Don vi") %></td>
				<td><aui:select name="donvi" label=""  style="width:200px">
						<aui:option value="0" >---Don vi---</aui:option>
						<% for(donvi dep1 : donviList) {%>
							<aui:option value="<%= dep1.getMadonvi() %>" selected="<%= dep1.getMadonvi() == hosoUpdate.getMadonvi() %>">  <%=dep1.getTendonvi() %></aui:option>
							<%
 								List<donvi> depByParent = donviLocalServiceUtil.getByParent(dep1.getMadonvi());
 								if(!depByParent.isEmpty()) {
 								for(donvi dep2 : depByParent) {
 							%> 
								<aui:option  value="<%=dep2.getMadonvi() %>" selected="<%= dep2.getMadonvi() == hosoUpdate.getMadonvi()%>" > &nbsp;&nbsp;&nbsp;&nbsp; <%= dep2.getTendonvi() %> </aui:option>
				
								<%} %>
							<%} %>
					<% }%>
					</aui:select></td>
			</tr>			 
		</table>
		
		
			<aui:button type="submit" value='<%=LanguageUtil.get(pageContext, "managecontacts.agency.add-button.save","Luu") %>'/>
			<aui:button type="button" value='<%=LanguageUtil.get(pageContext, "managecontacts.agency.add-button.cancel","Thoat") %>' onClick="history.back();"/>	
	</aui:form>

























